#include<iostream>
using namespace std;
int Find(int x)
{
	int n = x;
	while (n != father[n]) {
		n = father[n];
	}
	return n;
}
void Union(int x, int y)
{
	int A = Find(x);
	int B = Find(y);
	if (A != B)
	{
		father[A] = B;
	}
}